package com.scau.phradmin;

import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
import org.springframework.boot.web.servlet.server.ConfigurableServletWebServerFactory;
import org.springframework.boot.web.servlet.server.Session;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.http.HttpStatus;

import java.time.Duration;
import java.util.concurrent.TimeUnit;

/**
 * @author yuzhiyi
 * @date 2018/8/3 9:20
 */
@SpringBootApplication
@ComponentScan(basePackages = "com.scau.phradmin")
@MapperScan(basePackages = "com.scau.phradmin")
public class ServerBootstrap {

	public static void main(String[] args){
		SpringApplication.run(ServerBootstrap.class,args);
	}

	@Bean
	public ConfigurableServletWebServerFactory webServerFactory() {
		TomcatServletWebServerFactory factory = new TomcatServletWebServerFactory();
		Session session = new Session();
		session.setTimeout(Duration.ofDays(1));
		factory.setSession(session);
		//factory.setPort(9000);
		//factory.setSessionTimeout(10, TimeUnit.MINUTES);
		//factory.addErrorPages(new ErrorPage(HttpStatus.NOT_FOUND, "/notfound.html"));
		return factory;
	}

}
